package com.qzsoft.zhjd.materiel.modules.materieltareanalysis.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.qzsoft.zhjd.common.annotation.ZhjdDataFilter;
import com.qzsoft.zhjd.common.components.BaseServiceComponent;
import com.qzsoft.zhjd.materiel.modules.materieldata.dto.MaterielDataListDto;
import com.qzsoft.zhjd.materiel.modules.materieldata.service.MaterielDataService;
import com.qzsoft.zhjd.materiel.modules.materieltareanalysis.dto.MaterielTareChartDto;
import com.qzsoft.zhjd.materiel.modules.materieltareanalysis.dto.MaterielTareListDto;
import com.qzsoft.zhjd.materiel.modules.materieltareanalysis.mapper.MaterielTareAnalysisMapper;
import com.qzsoft.zhjd.materiel.modules.materieltareanalysis.service.MaterielTareAnalysisService;

/**
 * @ClassName MaterielTareAnalysisServiceImpl
 * @Description 车辆皮重业务接口实现
 * @author linhuawei
 * @since 2022-04-01
 */
@Service
public class MaterielTareAnalysisServiceImpl implements MaterielTareAnalysisService {

    @Autowired
    private MaterielTareAnalysisMapper materielTareAnalysisMapper;

    @Autowired
    private BaseServiceComponent baseServiceComponent;

    @Autowired
    private MaterielDataService materielDataService;

    @Override
    @ZhjdDataFilter(tableAlias = "t1")
    public IPage<MaterielTareListDto> page(Map<String, Object> params) {
        IPage<MaterielTareListDto> page = baseServiceComponent.getPage(params, MaterielTareListDto.class);
        return materielTareAnalysisMapper.queryDto(page, params);
    }

    @Override
    @ZhjdDataFilter(tableAlias = "t1")
    public IPage<MaterielDataListDto> pageForCar(Map<String, Object> params) {
        // 这里不能模糊查询
        if(ObjectUtils.isNotEmpty(params.get("carNumber"))) {
            params.put("carFullNumber", params.get("carNumber"));
            params.remove("carNumber");
        }
        return materielDataService.pageDto(params);
    }

    @Override
    @ZhjdDataFilter(tableAlias = "t1")
    public List<MaterielTareChartDto> chartForCar(Map<String, Object> params) {
        return materielTareAnalysisMapper.chartForCar(params);
    }

}
